package cn.tianya.irock.view;

import cn.tianya.irock.bll.Attachments;
import cn.tianya.irock.bll.Forums;
import cn.tianya.irock.bll.Posts;
import cn.tianya.irock.bll.Roles;
import cn.tianya.irock.bll.Searchs;
import cn.tianya.irock.bll.SiteManager;
import cn.tianya.irock.bll.Threads;
import cn.tianya.irock.core.DateTime;
import cn.tianya.irock.core.Page;
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.TemplateHashModel;
import freemarker.template.TemplateModelException;

public class MasterPage extends Page {

	@Override
	public void show() {
		core();
	}
	
	public void list() {
		core();
	}
	
	public void edit() {
		core();
	}

	private void core() {
		addItem("Threads", new Threads());
		addItem("Posts", new Posts());
		addItem("Attachments", new Attachments());
		addItem("SiteManager", new SiteManager());
		addItem("Roles", new Roles());
		addItem("Forums", new Forums());
		addItem("Searchs", new Searchs());
		addItem("DateTime", new DateTime());
		
		BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
		TemplateHashModel enumModels = wrapper.getEnumModels();
		TemplateHashModel roundingModeEnums;
		try {
			roundingModeEnums = (TemplateHashModel) enumModels.get("cn.tianya.irock.enums.SortThreadsBy");
			addItem("SortThreadsBy", roundingModeEnums); 
			
			roundingModeEnums = (TemplateHashModel) enumModels.get("cn.tianya.irock.enums.SortPostsBy");
			addItem("SortPostsBy", roundingModeEnums); 
		} catch (TemplateModelException e) {
		}		
	}
}
